<template>
  <div>
    <h3>个人设置</h3>
    <p>姓名: {{ userData.name }}</p>
    <p>性别: {{ userData.gender }}</p>
    <label for="phone">电话号码:</label>
    <input type="text" id="phone" v-model="userData.phone">
    <br>
    <button @click="saveSettings">保存</button>
  </div>
</template>
  
<script>
export default {
  props: ['userData'],
  methods: {
    saveSettings() {
      const phonePattern = /^1[3456789]\d{9}$/;
      if (!phonePattern.test(this.userData.phone)) {
        alert('请输入正确的手机号码');
        return;
      }
      console.log('保存设置:', this.userData.phone);
      alert('设置保存成功！');
      this.$router.push('/UserCenter/UserInfo');
    }
  }
};
</script>
  